#pragma once

#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")

#include <Windows.h>
#include <unordered_map>
#include <functional>

class Window {
public:
	Window(const std::wstring name, const DWORD style, const DWORD styleEx);
	virtual ~Window();

	static void host();

	void create();

	void dispose();

	void setVisible(const bool visible);

	void setSize(const int width, const int height);

	bool isCreated();

	void addListener(UINT, std::function<void(void)>);

protected:
	static const HINSTANCE hInstance;

	HWND parent;

	virtual bool registerClass();
	virtual bool unregisterClass();

	void setName(const std::wstring name);
	const std::wstring& getName() const;

	void setClassName(const std::wstring className);
	const std::wstring& getClassName() const;

	void setStyle(const DWORD style);

	void setExtendedStyle(const DWORD styleEx);

	bool isRegistered();

	virtual LRESULT processMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);

private:
	static std::unordered_map<HWND, Window*> windows;
	static Window* currInit;

	static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);

	HWND hwnd;
	std::wstring name;
	std::wstring className;
	int width;
	int height;
	int x;
	int y;
	DWORD style;
	DWORD styleEx;
	bool registered;
	//std::unordered_map<UINT, std::vector<std::function<void(void)>>> listeners;
};

